<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="jquery.min.js"></script>
    <script>
        var ws;
        $().ready(function ()
        {
            $('#conn').click(function ()
            {
                ws = new WebSocket('ws://127.0.0.1/Interesting/Connectx');
                $('#tips').text('正在连接');
                ws.onopen = function ()
                {
                    $('#tips').text('已经连接');
                }
                ws.onmessage = function (evt)
                {
                    $('#tips').text(evt.data);
                }
                ws.onerror = function (evt)
                {
                    $('#tips').text(JSON.stringify(evt));
                }
                ws.onclose = function ()
                {
                    $('#tips').text('已经关闭');
                }
            });

            $('#close').click(function ()
            {
                ws.close();
            });

            $('#send').click(function ()
            {
                if (ws.readyState == WebSocket.OPEN) {
                    ws.send($('#content').val());
                }
                else {
                    $('#tips').text('连接已经关闭');
                }
            });

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <input id="conn" type="button" value="连接" />
        <input id="close" type="button"  value="关闭"/>
        <span id="tips"></span>
        <input id="content" type="text" />
        <input id="send" type="button"  value="发送"/>
    </div>
    </form>
</body>